<template>
  <!-- 头部部分 -->
  <header class="header">
    <h1>todos</h1>
    <input
      v-model.trim="takname"
      @keydown.enter="add"
      class="new-todo"
      placeholder="请输入任务名称"
      autofocus
    />
  </header>
</template>

<script>
export default {
  name: "VuecliDemoTodoHeader",

  data() {
    return {
      takname: "",
    };
  },
  methods: {
    add() {
      if (this.takname === "") return;
      this.$emit("addTask", this.takname);
      this.takname = "";
    },
  },
};
</script>

<style lang="scss" scoped>
</style>